package com.shbt.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * TAuthorization entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_authorization", catalog = "default_schema")
public class TAuthorization implements java.io.Serializable {

	// Fields

	private Integer id;
	private TUser TUser;
	private String authorizationCode;
	private String canDoAction;
	private Set<TResource> TResources = new HashSet<TResource>(0);

	// Constructors

	/** default constructor */
	public TAuthorization() {
	}

	/** minimal constructor */
	public TAuthorization(Integer id, TUser TUser) {
		this.id = id;
		this.TUser = TUser;
	}

	/** full constructor */
	public TAuthorization(Integer id, TUser TUser, String authorizationCode,
			String canDoAction, Set<TResource> TResources) {
		this.id = id;
		this.TUser = TUser;
		this.authorizationCode = authorizationCode;
		this.canDoAction = canDoAction;
		this.TResources = TResources;
	}

	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "t_user_id", nullable = false)
	public TUser getTUser() {
		return this.TUser;
	}

	public void setTUser(TUser TUser) {
		this.TUser = TUser;
	}

	@Column(name = "authorization_code", length = 20)
	public String getAuthorizationCode() {
		return this.authorizationCode;
	}

	public void setAuthorizationCode(String authorizationCode) {
		this.authorizationCode = authorizationCode;
	}

	@Column(name = "can_do_action", length = 100)
	public String getCanDoAction() {
		return this.canDoAction;
	}

	public void setCanDoAction(String canDoAction) {
		this.canDoAction = canDoAction;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "TAuthorization")
	public Set<TResource> getTResources() {
		return this.TResources;
	}

	public void setTResources(Set<TResource> TResources) {
		this.TResources = TResources;
	}

}